<?php
session_start();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
	$id= $_POST['genid'];
	$source= $_REQUEST['source'];
	$hwsname= $_REQUEST['hwsname'];
	if($id==""){$id=1;}
}else{

	$id=1;
}

$values=$_SESSION["genForm"]["values"];
$errores=$_SESSION["genForm"]["errores"];

if(isset($errores)){ 
	if(isset($errores[name])){
		$errorname=$errores[name];
	}
	
	if(isset($errores[genSpice])){
		$errorspecie=$errores[genSpice];
	}
	
	if(isset($errores[codSus])){
		$errorcodsus=$errores[codSus];

	}
	if(isset($errores[BBlink])){
		$errorbblink=$errores[BBlink];

	}
	if(isset($errores[BDlink])){
		$errorbdlink=$errores[BDlink];

	}
	if(isset($errores[fasta])){
		$errorfasta=$errores[fasta];

	}
}else{

	$errorname="";
	$errorspecie="";
	$errorcodsus="";
	$errorbblink="";
	$errorbdlink="";
	$errorfasta="";
}


?>


<div id="formGen<?php echo $id;?>">

<fieldset>
<legend>Gen data</legend>
<form id="GenForm" onsubmit="return val_gen(<?php echo $id;?>)" action="genFormVal.php?id=<?php echo $id;?>" method="post">

<div id="div_g_name<?php echo $id;?>"><label
	id="label_g_name<?php echo $id;?>" for="g_name">Name:</label> <input
	id="g_name<?php echo $id;?>" name="g_name<?php echo $id;?>" type="text" value="<?php if(isset($values[name])){ echo $values[name]; }?>" />
	<?php 
	if($errorname){
		?>
		<span id="span_gen_name<?php echo $id;?>"  class="errorForm";><?php echo $errorname;?></span>
        <?php
	}else{
		?>
		<span id="span_gen_name<?php echo $id;?>">What's the gen name?</span>
        <?php	
	}
	?>
	</div>

<div id="div_spice<?php echo $id;?>"><label
	id="label_g_spice<?php echo $id;?>" for="g_spice">Spieces:</label> <input
	id="g_spice<?php echo $id;?>" name="g_spice<?php echo $id;?>" type="text" value="<?php if(isset($values[spice])){ echo $values[spice]; }?>" />
	<?php 
	if($errorspecie){
		?>
		<span id="span_gen_spice<?php echo $id;?>"  class="errorForm";><?php echo $errorspecie;?></span>
        <?php
	}else{
		?>
		<span id="span_gen_spice<?php echo $id;?>">What specie does the gen belong?</span>
        <?php	
	}
	?>	
	</div>

<div id="div_g_codSus<?php echo $id;?>"><label
	id="label_g_codSus<?php echo $id;?>" for="bb_g_codSus">Encoding
substance:</label> <input id="bb_g_codSus<?php echo $id;?>"
	name="bb_g_codSus<?php echo $id;?>" type="text" value="<?php if(isset($values[codSus])){ echo $values[codSus]; }?>" />
	<?php 
	if($errorcodsus){
		?>
		<span id="span_gen_codsus<?php echo $id;?>"  class="errorForm";><?php echo $errorcodsus;?></span>
        <?php
	}else{
		?>
		<span id="span_gen_codsus<?php echo $id;?>">What's substance does it enconde?</span>
        <?php	
	}
	?>	
	</div>

<div id="div_g_linkBB<?php echo $id;?>"><label
	id="label_g_linkBB<?php echo $id;?>" for="bb_g_linkBB">BioBit link:</label>
<input id="bb_g_linkBB<?php echo $id;?>" name="bb_g_linkBB<?php echo $id;?>" type="text"
	value="<?php if(isset($values[linkbb])){ echo $values[linkbb]; }?>" />
	
	<?php 
	if($errorbblink){
		?>
		<span id="span_gen_bblink<?php echo $id;?>"  class="errorForm";><?php echo $errorbblink;?></span>
        <?php
	}else{
		?>
		<span id="span_gen_bblink<?php echo $id;?>">BioBrick link</span>
        <?php	
	}
	?>		
	</div>

<div id="div_g_linkBD<?php echo $id;?>"><label
	id="label_g_linkBD<?php echo $id;?>" for="bb_g_linkBD">Database link:</label>
<input id="bb_g_linkBD<?php echo $id;?>" name="bb_g_linkBD<?php echo $id;?>" type="text"
	value="<?php if(isset($values[linkbd])){ echo $values[linkbd]; }?>" />
	<?php 
	if($errorbdlink){
		?>
		<span id="span_gen_bdlink<?php echo $id;?>"  class="errorForm";><?php echo $errorbdlink;?></span>
        <?php
	}else{
		?>
		<span id="span_gen_bdlink<?php echo $id;?>">Other database link</span>
        <?php	
	}
	?>	
	
	</div>

<div id="div_g_fasta<?php echo $id;?>"><label
	id="label_g_fasta<?php echo $id;?>" for="bb_g_fasta">FASTA seq:</label>
<input id="bb_g_fasta<?php echo $id;?>" name="bb_g_fasta<?php echo $id;?>" type="text"
	value="<?php if(isset($values[fasta])){ echo $values[fasta]; }?>" />
	<?php 
	if($errorfasta){
		?>
		<span id="span_gen_fasta<?php echo $id;?>"  class="errorForm";><?php echo $errorfasta;?></span>
        <?php
	}else{
		?>
		<span id="span_gen_fasta<?php echo $id;?>">Fasta secuence</span>
        <?php	
	}
	?>	
	
	</div>

<input type="hidden" id="source" name="source" value="<?php echo $source ?>">
<input type="hidden" id="hwsname" name="hwsname" value="<?php echo $hwsname ?>">

<div class="botonMolon" id="div_submitGen<?php echo $id;?>">
<button id="submitGen<?php echo $id;?>">Send</button>
</div>
</form>
</fieldset>
</div>